/**
 * 弹窗确认 类似confirm方法,防止浏览器禁用confirm
 * 创建controller时需要引入 ngDialog
 *
 *  例
 * openDialog(ngDialog,$scope,'确定要关闭?',function (val) {
        alert(val);
    });
 * @param ngDialog
 * @param $scope
 * @param showMsg 弹窗需要显示的内容
 * @param dialogNo 是否显示"否"按钮
 * @param dialogYes 是否显示"是"按钮
 * @param dialogClose 是否显示"关闭"按钮
 * @param callbackFun 点击弹窗按钮时回调函数,点击是返回true,否返回false,关闭返回close
 */

function openDialog(ngDialog, $scope, showMsg, dialogNo, callbackFun) {
    openDialogBase(ngDialog, $scope, showMsg, dialogNo, true, false, callbackFun);
};

function openDialogText(ngDialog, $scope, showMsg, dialogNo, no_text, yes_text, callbackFun) {
    openDialogBaseText(ngDialog, $scope, showMsg, dialogNo, true, false, no_text, yes_text, '', callbackFun);
};

function openDialogAlert(ngDialog, $scope, showMsg) {
    openDialogBase(ngDialog, $scope, showMsg, false, false, true, function () {
    });
};

function openDialogBase(ngDialog, $scope, showMsg, dialogNo, dialogYes, dialogClose, callbackFun) {
    $scope.dialogHtml = showMsg;
    $scope.dialogNo = dialogNo;
    $scope.dialogYes = dialogYes;
    $scope.dialogClose = dialogClose;
    $scope.no_text = '否';
    $scope.yes_text = '是';
    $scope.close_text = '关闭';
    ngDialog.open({
        template: 'popupConfirm.html',
        scope: $scope,
        preCloseCallback: callbackFun
    });
};

function openDialogBaseText(ngDialog, $scope, showMsg, dialogNo, dialogYes, dialogClose,no_text, yes_text, close_text, callbackFun) {
    $scope.dialogHtml = showMsg;
    $scope.dialogNo = dialogNo;
    $scope.dialogYes = dialogYes;
    $scope.dialogClose = dialogClose;
    $scope.no_text = no_text;
    $scope.yes_text = yes_text;
    $scope.close_text = close_text;
    ngDialog.open({
        template: 'popupConfirm.html',
        scope: $scope,
        preCloseCallback: callbackFun
    });
};